package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.entity.AfoneshopTopic;
import com.example.demo.mapper.AfoneshopTopicMapper;
import com.example.demo.service.IAfoneshopTopicService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.bouncycastle.jcajce.provider.symmetric.AES;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 主题精选 服务实现类
 * </p>
 *
 * @author Mr.We
 * @since 2024-06-22
 */
@Service
public class AfoneshopTopicServiceImpl extends ServiceImpl<AfoneshopTopicMapper, AfoneshopTopic> implements IAfoneshopTopicService {
    @Resource
    private AfoneshopTopicMapper afoneshopTopicMapper;

    @Override
    public AfoneshopTopic queryObject(Integer id) {
        return afoneshopTopicMapper.queryObject(id);
    }

    @Override
    public List<AfoneshopTopic> queryList(Map<String, Object> map) {
        return afoneshopTopicMapper.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return afoneshopTopicMapper.queryTotal(map);
    }

    @Override
    public boolean save(AfoneshopTopic topic) {
        if (topic != null){
            afoneshopTopicMapper.insert(topic);
            return true;
        }
        return false;
    }


    public void update(AfoneshopTopic topic) {
        QueryWrapper<AfoneshopTopic> wrapper = new QueryWrapper<>();
        wrapper.eq("id",topic.getId());
        afoneshopTopicMapper.update(wrapper);
    }


    public void delete(Integer id) {
        QueryWrapper<AfoneshopTopic> wrapper = new QueryWrapper<>();
        wrapper.eq("id",id);
        afoneshopTopicMapper.delete(wrapper);
    }


    public void deleteBatch(Integer[] ids) {
        QueryWrapper<AfoneshopTopic> wrapper = new QueryWrapper<>();
        wrapper.in("id", (Object) ids);
        afoneshopTopicMapper.delete(wrapper);
    }
}
